﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GKQC.Common
{
    public partial class FormProductCode : Form
    {
        public FormProductCode()
        {
            InitializeComponent();
        }

        //清除
        private void button2_Click(object sender, EventArgs e)
        {
            txtPn.Text = string.Empty;
            foreach(Control c in groupBox1.Controls)
            {
                if(c is TextBox)
                    c.Text = string.Empty;
            }
        }

        //解析
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                MaterialCodeSplit();
            }
            catch(Exception ex)
            {
                Logger.LogError(ex);
            }
        }

        void MaterialCodeSplit()
        {
            txtSeries.Text = ProductCode.GetSeriesCode(txtPn.Text);
            txtVoltageCode.Text = ProductCode.GetVoltageCode(txtPn.Text);
            txtVoltage.Text = ProductCode.GetVoltage(txtPn.Text).ToString();
            txtCapRateCode.Text = ProductCode.GetCapRateCode(txtPn.Text);
            double capRateMin, capRateMax;
            ProductCode.GetCapRate(txtPn.Text, out capRateMin, out capRateMax);
            txtCapRate.Text = capRateMin.ToString() + "~" + capRateMax.ToString();
            txtCapCode.Text = ProductCode.GetCapCode(txtPn.Text);
            txtCap.Text = ProductCode.GetCap(txtPn.Text).ToString();
            txtDCode.Text = ProductCode.GetDCode(txtPn.Text);
            txtD.Text = ProductCode.GetD(txtPn.Text).ToString();
            txtLCode.Text = ProductCode.GetLCode(txtPn.Text);
            txtL.Text = ProductCode.GetL(txtPn.Text).ToString();
            txtSpecialCode.Text = ProductCode.GetSpecialCode(txtPn.Text);
            txtCustomerCode.Text = ProductCode.GetCustomerCode(txtPn.Text);
            txtMakeCode.Text = ProductCode.GetMakeCode(txtPn.Text);
            txtFlagCode.Text = ProductCode.GetFlagCode(txtPn.Text);
        }
    }
}
